// check.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrls: [],
    indicatorDots: true,
    autoplay: true,
    interval: 5000,
    duration: 1000,
    navs: [],
    recommend: [],
    copyright: '',
    windowWidth: 0,
    windowHeight: 0
  },
  /**
   * 点击应用分类
   */
  navTap: function (e) {
    var nav_id = e.currentTarget.dataset.id;
    console.log(nav_id);
    wx.navigateTo({
      url: '../search/search?id=' + nav_id
    })
  },
  /**
   * 点击查看应用详情
   */
  itemTap: function (e) {
    var item_id = e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '../app_info/app_info?id=' + item_id,
    })
  },
  /**
   * 推荐应用查看全部
   */
  recommendMoreTap: function () {
    wx.navigateTo({
      url: '../search/search?id=0',
    })
  },
  /**
   * 获取列表
   */
  getAppList: function () {
    var that = this;
    app.util.request({
      'url': 'entry/wxapp/category',
      data: {
        m: 'llt_xappsc'
      },
      success: function (res) {
        var tmpData = res.data.data
        that.setData({
          imgUrls: tmpData.slide,
          navs: tmpData.category,
          recommend: tmpData.recommend,
          copyright: tmpData.copyright

        })
        console.log(res)
        wx.stopPullDownRefresh();
      }
    });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          windowWidth: res.windowWidth,
          windowHeight: res.windowHeight
        })
      },
    })
    this.getAppList();
  },
  /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
  onPullDownRefresh: function () {
    this.getAppList();
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})